import { allCompany } from '../api/baseSetting';

//test
export const increment = ({ commit }) => {
    commit('INCREMENT')
}
export const decrement = ({ commit }) => {
    commit('DECREMENT')
}
//获取公司列表
export const getCompany = ({ commit, state }) => {
    return new Promise((resolve, rejects) => {
        if (state.companyList.length > 0) {
            resolve(state.companyList)
        } else {
            allCompany().then(res => {
                console.log(res);
                commit('setCompanyList',res);
                resolve(res);
            })
        }
    })
}
//获取token
export const getToken = ({commit,state})=>{
    if(state.token){
        return state.token
    }else{
        var token = sessionStorage.getItem('token');
        if(token){
            commit.setToken(token);
            return token
        }else{
            return false;
        }
    }
}
